package com.xin.data.simbapesa.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.xin.data.simbapesa.base.BaseBindingAdapter1;
import com.xin.data.simbapesa.databinding.SimbaBindcardItemBinding;
import com.xin.data.simbapesa.obj.SimbaWalletChannel;

import java.util.List;

public class BindCardAdapter extends BaseBindingAdapter1<SimbaWalletChannel, SimbaBindcardItemBinding> {


    int index;

    public BindCardAdapter(List<SimbaWalletChannel> dataList) {
        super(dataList);
    }

    @Override
    protected void bindData(SimbaBindcardItemBinding binding, SimbaWalletChannel item, int position) {
        Glide.with(binding.getRoot().getContext()).load(item.getLogo()).into(binding.tvIcon);
        binding.tvTitle.setText(item.getDesc());
        if (index == position) {
            binding.tvRoot.setSelected(true);
            binding.tvBox.setVisibility(View.VISIBLE);
        } else {
            binding.tvRoot.setSelected(false);
            binding.tvBox.setVisibility(View.GONE);
        }

        binding.tvRoot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onBtnItemClickListener != null) {
                    onBtnItemClickListener.onItemClick(position);
                }
            }
        });

    }

    @Override
    protected int getItemType(SimbaWalletChannel item) {
        return 0;
    }

    @Override
    protected SimbaBindcardItemBinding createBinding(LayoutInflater inflater, ViewGroup parent, int viewType) {
        return SimbaBindcardItemBinding.inflate(inflater);
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
